﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HPortal.Lib;
using System.Data;

namespace HPortal.Module
{
    public partial class AticleGroupList : PanelControl
    {
        protected int ChannelID;
        DataTable tbArticleGroupLst = new DataTable();
        //DataTable tbChannelID = new DataTable();
        String menu = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            GetChannel("", 0);
            // menu += "<li><a href = \"/Backend\">Quản lý</a><ul></ul></li>";
            menu = menu.Replace("<ul></ul>", "");
            Aticlegroup.Text = "<ul id=\"sf_menu1\">" + menu + "</ul>";
        }
        public String GetChannel(String PrentID, int bien)
        {
            ChannelID = DatabaseHelper.SelectScalarIntFromID("ChannelID", "Panel", PanelID);
            String sql = "Select * from ArticleGroup where ParentID = '" + PrentID + "'";
            tbArticleGroupLst = DatabaseHelper.Select("exec getAticlelist_group " + Int32.Parse(PanelID.ToString()));
           
          //  DataTable tbArticleGroup = DatabaseHelper.Select(sql);
            int i = 0;
            String idLi = "";
            String idUl = "";
            String idA = "";
            String classLi = "menuli" + bien;
            String classUl = "menuul" + bien;
            String classA = "menuA";
            String styleUl = "";

            while (i < tbArticleGroupLst.Rows.Count)
            {
                String linkhref = "/default.aspx?url=Module/ArticleList.ascx&GroupID=" + tbArticleGroupLst.Rows[i]["GroupID"].ToString() + "&PanelID=" + PanelID + "&ChannelID=" + ChannelID + "";
                String nameLink = tbArticleGroupLst.Rows[i]["Title"].ToString();
                menu += "<li class=\"" + classLi + "\" ><a id=\"" + idA + "\" class=\"" + classA + "\"  href = \"" + linkhref + "\">" + nameLink + "</a><ul class=\"" + classUl + "\">";
            //    GetChannel(tbArticleGroupLst.Rows[i]["GroupID"].ToString(), i);
                menu += "</ul></li>";
                i++;
            }
            return menu;
        }
    }
}